﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Management/Manage.Master"  %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Show Menu
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
 <script type="text/javascript">
     $(document).ready(function () {

         $("a").removeClass("current");
         $("#menus").addClass("current");
         var e = jQuery.Event("click");
         $("#menus").trigger(e);
         $("#list-menu").addClass("current");

     });

     function Delete(id) {
         var answer = confirm("Do you want to delete this menu?")
         if (answer) {
             DeleteMenu(id);
         }

         return false;
     }

     function DeleteMenu(id) {


         $("#results").html("");
         $.ajax({
             type: "POST",
             url: "/Management/DeleteMenu/" + id,
             error: function (xhr, status, error) {
             },
             success: function (response) {
                 if (response != null) {
                     if (!response.Successful) {
                         $("#results").html("An error occurred: " + response.Exception).addClass("red");
                         return false;
                     }
                     else {
                        // window.opener.location.reload();
                         window.location.reload();
                        $("#results").html("Menu Deleted Successfully: ").addClass("green");
                     }
                 }
             }
         });

     }
        
</script>
<div class="content-box">
        <!-- Start Content Box -->
        <div class="content-box-header" style="padding:4px 0px 0px 10px;">
            <h3>Show Menus</h3>
            <div class="clear">
            </div>
        </div>
          <div class="content-box-content">
          <div id="results"></div>
          <div class="tab-content default-tab" id="tab1">
            <table>
                    <thead>
                    <tr>
                    <th>Name</th>
                    <th>Order</th>
                    <th colspan="2" >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Actions</th>
                    </tr>
                    </thead>
                    <tbody>
                    <% foreach (var menu in (IList<CSI.Directory.Core.Model.Menu>)ViewData["menu"])
                    {%>
                    <tr>
                    <td><%=menu.Name%></td>
                    <td><%=menu.Order%></td>
                   <%-- <td><a href="<%= ResolveUrl("~/management/EditMenu/" + menu.Id) %>">Edit</a> </td>--%>
                   <td><a href="/Management/EditMenu/<%= menu.Id%>">Edit</a> </td>
                   <%-- <td><a href="<%= ResolveUrl("~/management/delete/" + menu.Id) %>" onclick="Delete(<%= article.Id%>);">Delete</a></td>--%>
                     <td><a href="" onclick="Delete(<%= menu.Id%>);">Delete</a></td>
                    </tr>
                    <%} %>
                    </tbody>
            </table>
           </div>
        </div>
  </div>
    
</asp:Content>
